package dao

import (
	"fmt"

	"gorm.io/gorm"
)

type Base struct{}

func (b *Base) UpdateTime(db *gorm.DB, UpdateTime []string) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		if len(UpdateTime) != 2 {
			return db
		} else {
			return db.Where("update_time > ? AND update_time < ?", UpdateTime[0], UpdateTime[1])
		}
	}
}

func (b *Base) CreateTime(db *gorm.DB, CreateTime []string) func(db *gorm.DB) *gorm.DB {
	fmt.Println(CreateTime)
	return func(db *gorm.DB) *gorm.DB {
		if len(CreateTime) != 2 {
			return db
		} else {
			return db.Where("create_time > ? AND create_time < ?", CreateTime[0], CreateTime[1])
		}
	}
}

var BaseDao = new(Base)
